﻿using System;
using System.Collections.Generic;
using System.Text;

namespace HippoScript
{
    public class JSAnalyze : AnalyzeBase
    {
        public static string IMPORT = "import";//脚本import内容的key
        public static string REFERENCED = "referenced";//脚本referenced内容的key
        public static string CODEMODULE = "codeModule";//脚本codeModule内容的key
        public override ScriptContext AnalyzeString(string src)
        {
            ScriptContext context = new ScriptContext();
            Dictionary<string, string> dicSrc = StringMapParser.Parser(src);
            if (dicSrc.ContainsKey(IMPORT))
            {
                context.AddUsing(dicSrc[IMPORT]);
            }
            if (dicSrc.ContainsKey(REFERENCED))
            {
                context.AddReferencedAssembly(dicSrc[REFERENCED]);
            }
            if (dicSrc.ContainsKey(CODEMODULE))
            {
                context.AddCode(dicSrc[CODEMODULE]);
            }
            return context;
        }
    }
}
